function [Y, periodStartConditions] = generate_fullmodel_sequence_ctsTime(indivConfigs, initialConditions, XbetaFixed, Xdynamic_staticInputs, paramsParts)
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	% This function generates a sequence of adoptions / exits according to a continuous-time model, but adoptions and exits are aggregated
	% at the daily level.
	%
	%   - XbetaFixed is sums up the utility parts that do not vary at the (t-k) level (hence will not change
	%   as a function of laggedConsumers/ laggedProviders).
	%
	%  - Xdynamic_staticInputs contains the data parts at the (t-k) level (variables that do not depend on laggedConsumers and laggedProviders).
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%%%%% Inputs:
	% indivConfigs:						object
	%	.consumerAdoptions:					object (as obtained by calling getConfig_consumerAdoptions)
	%	.providerAdoptions:					object (as obtained by calling getConfig_providerAdoptions)
	% initialConditions:				object:
	%	.laggedConsumersOrig:					K1 x 1
	%	.laggedConsumersDest:					K2 x 1
	%	.laggedProviders:						K x 1
	%	.popAtRisk:							object
	%		.providerAdoptions:					K x 1
	%		.consumerAdoptions:					K x 1
	%
	% XbetaFixed:						object:
	%	.consumerAdoptions:					K1 x K2 x T
	%	.providerAdoptions:					K x T
	%	.providerExits:						K x T
	%
	% Xdynamic_staticInputs:			object  (static inputs that, combined with laggedBases, serve to compute the Xparts
	%													that are impacted by lagged Y, --> these are the "static" things that do not change)
	%	.providerAdoptions:					object:
	%		.Xparts_static:						cell(NumParts, 1):
	%			{1}:								object:
	%				.X:									K x NumXstatic x T
	%				.X_FEs:								K x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%	.consumerAdoptions:					object:
	%		.Xparts_static:						cell(NumParts, 1):
	%			{2}:								object:
	%				.X:									K1 x NumXstatic x T
	%				.X_FEs:								K1 x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%			{3}:								object:
	%				.X:									K2 x NumXstatic x T
	%				.X_FEs:								K2 x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%
	% paramsParts:						object:
	%	.consumerAdoptions:					cell(NumParts,1)
	%	.providerAdoptions:					cell(NumParts,1)
	%	.providerExits:						cell(NumParts,1)
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%%%%% Outputs:
	% Y:								object
	%	.consumerAdoptions:					sparse([T x (K1*K2)])
	%	.providerAdoptions:					T x K
	%	.providerExits:						T x K
	% periodStartConditions:			cell(T,1):
	%	{tt}:								object:
	%		.laggedProviders:						K x 1
	%		.laggedConsumersOrig:					K x 1
	%		.laggedConsumersDest:					K x 1
	%		.popAtRisk:							obj:
	%			.providerAdoptions:					K x 1
	%			.consumerAdoptions:					K x 1
	%		.randomState:						obj (as obtained by calling rng)
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		
	disp('Using the continuous-time model to generate a sequence...');
		
	% Read dimensions
	[K,T]       = size(XbetaFixed.providerAdoptions);
	[K1, K2, ~] = size(XbetaFixed.consumerAdoptions);
	
	%%%%% Initialize data structures to store results
	Y.providerAdoptions  = zeros(K,T);
	Y.providerExits      = zeros(K,T);
	Y.consumerAdoptions = sparse(K1*K2,T);
	periodStartConditions = cell(T,1);
	
	%%%%% Initialize installed bases and populations at risk
	laggedConsumersOrig         = initialConditions.laggedConsumersOrig; % K1 x 1
	laggedConsumersDest         = initialConditions.laggedConsumersDest; % K2 x 1
	laggedProviders              = initialConditions.laggedProviders; % K x 1
	popAtRisk                 = initialConditions.popAtRisk; % object
	popAtRisk.providerExits      = laggedProviders; % K x 1
	
	%%%%% Loop over time periods
	for tt = 1:T
		% Store conditions at start of period tt
		periodStartConditions{tt}.laggedProviders      = laggedProviders;
		periodStartConditions{tt}.laggedConsumersOrig = laggedConsumersOrig;
		periodStartConditions{tt}.laggedConsumersDest = laggedConsumersDest;
		periodStartConditions{tt}.popAtRisk         = popAtRisk;
		periodStartConditions{tt}.randomState       = rng;
		
		%%% Start day tt
		Tleft = 1;                           % time left until end of period tt
		Y_providerAdoptions_tt  = zeros(K,1);   % number of provider adoption events within period tt
		Y_providerExits_tt      = zeros(K,1);   % number of provider exit events within period tt
		Y_consumerAdoptions_tt = zeros(K1,K2); % number of consumer adoption events within period tt
		
		while Tleft > 0
			% Get rates of arrival of events (updated every time a new event happens)
			installedBases.laggedConsumersOrig = laggedConsumersOrig;
			installedBases.laggedConsumersDest = laggedConsumersDest;
			installedBases.laggedProviders      = laggedProviders;
			arrivalRates_tt = getArrivalRates(indivConfigs, popAtRisk, paramsParts, XbetaFixed, Xdynamic_staticInputs, installedBases, tt);
			
			% Get sum of arrival rates (across all types of events)
			lambda_consumerAdoptions = arrivalRates_tt.consumerAdoptions;     % K1 x K2
			lambda_providerExits      = arrivalRates_tt.providerExits;           % K  x 1
			lambda_providerAdoptions  = arrivalRates_tt.providerAdoptions;       % K  x 1
			
			lambda_ttl_consumerAdoptions = sum(lambda_consumerAdoptions(:)); % 1 x 1
			lambda_ttl_providerExits      = sum(lambda_providerExits);      % 1 x 1
			lambda_ttl_providerAdoptions  = sum(lambda_providerAdoptions);  % 1 x 1
			
			lambda_total = lambda_ttl_consumerAdoptions + lambda_ttl_providerAdoptions + lambda_ttl_providerExits; % 1 x 1
			
			% Simulate time to next event
			A = draw_Exponential(lambda_total, 1); % 1 x 1
			
			% If event happens before end of the day: record it, update everything, reduce time left before end of day and iterate
			if A < Tleft
				% Figure out what type of event happened: provider adoption, provider exit or consumer adoption (multinomial probs)
				cond_probs = [lambda_ttl_consumerAdoptions; lambda_ttl_providerAdoptions; lambda_ttl_providerExits]./lambda_total; % 3 x 1
				evt_type = find(mnrnd(1,cond_probs)==1); % integer between 1 and 3
				clear cond_probs;
				
				%%% Case of consumerAdoption
				if evt_type == 1
					% Draw origin of event
					cond_probs = sum(lambda_consumerAdoptions,2)./lambda_ttl_consumerAdoptions; % K1 x 1
					k1 = find(mnrnd(1,cond_probs)==1); % index between 1 and K1
					% Draw destination of event
					cond_probs = lambda_consumerAdoptions(k1,:)'; cond_probs = cond_probs./sum(cond_probs); % K2 x 1
					k2 = find(mnrnd(1,cond_probs)==1); % index between 1 and K2
					% Record event
					Y_consumerAdoptions_tt(k1,k2) = Y_consumerAdoptions_tt(k1,k2) + 1;
					
					% Update installed base and popAtRisk
					laggedConsumersOrig(k1)             = laggedConsumersOrig(k1) + 1;
					laggedConsumersDest(k2)             = laggedConsumersDest(k2) + 1;
					popAtRisk.consumerAdoptions(k1) = popAtRisk.consumerAdoptions(k1) - 1;
					
					% Clean up
					clear cond_probs k1 k2;
				end
				
				%%% Case of providerAdoption
				if evt_type == 2
					% Draw location of event
					cond_probs = lambda_providerAdoptions./lambda_ttl_providerAdoptions; % K x 1
					kk = find(mnrnd(1,cond_probs)==1); % index between 1 and K
						
					% Record event
					Y_providerAdoptions_tt(kk) = Y_providerAdoptions_tt(kk) + 1;
					
					% Update installed base and popAtRisk
					laggedProviders(kk)             = laggedProviders(kk) + 1;
					popAtRisk.providerAdoptions(kk) = popAtRisk.providerAdoptions(kk) - 1;
					popAtRisk.providerExits(kk)     = popAtRisk.providerExits(kk) + 1;
					
					% Clean up
					clear cond_probs kk;
				end
				
				%%% Case of providerExit
				if evt_type == 3
					% Draw location of event
					cond_probs = lambda_providerExits./lambda_ttl_providerExits; % K x 1
					kk = find(mnrnd(1,cond_probs)==1); % index between 1 and K
					
					% Record event
					Y_providerExits_tt(kk) = Y_providerExits_tt(kk) + 1;
					
					% Update installed base and popAtRisk
					laggedProviders(kk)             = laggedProviders(kk) - 1;
					popAtRisk.providerAdoptions(kk) = popAtRisk.providerAdoptions(kk) + 1;
					popAtRisk.providerExits(kk)     = popAtRisk.providerExits(kk) - 1;
					
					% Clean up
					clear cond_probs kk;
				end
				clear evt_type;

				% Reduce time left
				Tleft = Tleft - A;
			
			% If event happends after end of day: discard it, declare day over
			else
				Tleft = 0;
			end
		end
		displayRemainingTime(tt, T, 20);
		
		% Save Ys predicted into data structures
		Y.providerAdoptions(:,tt)  = Y_providerAdoptions_tt;
		Y.providerExits(:,tt)      = Y_providerExits_tt;
		Y.consumerAdoptions(:,tt) = reshape(Y_consumerAdoptions_tt, [K1*K2 1]);
	end
	
	% Combine everything together in Y
	Y.consumerAdoptions = Y.consumerAdoptions'; % [T x K] or [T x (K1*K2)]
	Y.providerAdoptions  = Y.providerAdoptions';  % T x K
	Y.providerExits      = Y.providerExits';      % T x K
end
